<template>
    <div class="title">
        <div>===================================使用pinia组件(vuex替代品)===================================</div>
        <div>
            pinia中counter的值:{{ store.counter }}
        </div>
        <div>
            pinia中doubleCount的值:{{ store.doubleCount }}
        </div>
        <button @click="getPinia">打印pinia实例</button>
        <button @click="getPiniaCounter">打印pinia中的counter</button>
        <button @click="getPiniaActions">调用pinia中的actions</button>
        <div>
            pinia放弃了vuex的mutation，直接使用actions代替，可在其中写异步与同步
        </div>
    </div>
</template>

<script setup lang="ts">
import { useCounterStore } from "@/stores/counter"

const store = useCounterStore()


function getPinia() {
    console.log(store)
}
function getPiniaCounter() {
    console.log(store.counter)
}
function getPiniaActions() {
    store.increment()
}
</script>

<style>
.title {
    padding: 10px;
    font-size: 18px;
    font-weight: 600;
}
</style>